var domain = 'https://dxx.gylxpsy.com:10021'
// var domain = 'http://127.0.0.1:8888'https://dxx.gylxpsy.com:10021
function initData () {
    var d = new Date() // 设置一个字符串表示的日期对象
    // yy = d.getFullYear() // 取满年
    $('#kyear').html(d.getFullYear() + ' 年 ' + (d.getMonth() < 10 ? ('0' + (d.getMonth() + 1)) : (d.getMonth() + 1)) + ' 月 ' + (d.getDate() < 10 ? ('0' + d.getDate()) : d.getDate()) + ' 日')
    $('#ktime').html((d.getHours() < 10 ? ('0' + d.getHours()) : d.getHours()) + ' : ' + (d.getMinutes() < 10 ? ('0' + d.getMinutes()) : d.getMinutes()))
}

$(document).on('click', '#goIndex', function (event) {
    window.location.href = 'index.html'
})
$(document).on('click', '.goIndex', function (event) {
    window.location.href = 'index.html'
})
$(document).on('click', '.goBack', function (event) {
    history.go(-1)
})

$(document).on('click', '#windowClose', function () {
    $('.window').hide()
})

$(document).on('click', '.fapiao', function () {
    localStorage.setItem('tag', 'fapiao')
    window.location.href = '2.html'
})

$(document).on('click', '.baogao', function () {
    localStorage.setItem('tag', 'baogao')
    window.location.href = '2.html'
})

var timeOut = 60

function daojishi () {
    $('#timeOut').html(timeOut + ' 秒')
    setInterval(function () {
        $('#lastTime').val(timeOut)
        timeOut = timeOut - 1
        if (timeOut <= 0) {
            window.location.href = 'index.html'
        } else {
            $('#timeOut').html(timeOut + ' 秒')
        }
    }, 1000)
}

function fapiaoInit () {
    var fapiaoData = localStorage.getItem('fapiaoData')
    let html = ''
    if (fapiaoData) {
        const fapiaoJSON = JSON.parse(fapiaoData)
        for (let i = 0; i < fapiaoJSON.length; i++) {
            html += '<tr>' +
                '       <td >' + fapiaoJSON[i].billNo +
                '       </td><td>济南市儿童医院</td><td>' + fapiaoJSON[i].amount + '</td>' +
                '       <td>门诊</td>' +
                '       <td>' + fapiaoJSON[i].busDateTime +
                '       </td>' +
                '       <td>' +
                '           <input type="radio" value="' + i + '" name="checkIndex">\n' +
                '       </td>' +
                '   </tr>'
        }
    }
    if (html) {
        $('#fapiaoId').html(html)
    } else {
        $('#fapiaoId').html(html)
        $('.emptyTag').show()
    }
}

function baogaoInit () {
    var fapiaoData = localStorage.getItem('baogaoData')
    let html = ''
    if (fapiaoData) {
        const fapiaoJSON = JSON.parse(fapiaoData)
        for (let i = 0; i < fapiaoJSON.length; i++) {
            html += '<tr>' +
                '       <td >' + fapiaoJSON[i].reportProject +
                '       </td><td>济南市儿童医院</td><td>' + fapiaoJSON[i].amount + '</td>' +
                '       <td>检验</td>' +
                '       <td>' + fapiaoJSON[i].resultDate +
                '       </td>' +
                '       <td>' +
                '           <input type="radio" value="' + i + '" name="checkIndex" checked>\n' +
                '       </td>' +
                '   </tr>'
        }
    }
    if (html) {
        $('#fapiaoId').html(html)
    } else {
        $('#fapiaoId').html(html)
        $('.emptyTag').show()
    }
}

$(function () {
    initData()
    setInterval(function () {
        initData()
    }, 50)
    $('#username').html('就诊人 : ' + localStorage.getItem('username'))
    $('#useridcard').html('证件号 : ' + localStorage.getItem('useridcard'))
})
